package com.qishen.serviceImpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qishen.mapper.StoreMapper;
import com.qishen.pojo.Store;
import com.qishen.service.StoreService;
import lombok.extern.log4j.Log4j;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
@Log4j2
public class StoreServiceImpl extends ServiceImpl<StoreMapper,Store> implements StoreService {
    @Autowired
    private StoreMapper storeMapper;


    @Override
    public IPage<Store> findAll(int page,int pageSize) {
        if (StringUtils.isEmpty(page)){
            page=0;
        }
        if (StringUtils.isEmpty(pageSize)){
            pageSize=10;
        }

        IPage<Store> storePage = new Page<>(page,pageSize);
        if (StringUtils.isEmpty(storePage)){
            log.error("查询数据不存在");
        }
        storeMapper.selectPage(storePage, null);
        List<Store> storeList = storePage.getRecords();
        long pages = storePage.getPages();
        return storePage;
    }
}
